import React from 'react';
import { Redirect } from 'umi';
import { connect } from 'dva';

function auth({ user, children }) {
    if (user && user.name == 'admin') {
        //alert(1);
        return <React.Fragment>{children}</React.Fragment>;
        //return <Redirect to="/dashboard/index" />
    } else {
        return <Redirect to="/login" />;
    }
}

export default connect(function(state) {
    return {
        user: state.user.user, //第一个user是命名空间
    };
})(auth);
